attribute vec4 aPosition;
attribute vec4 aTextureCoord;
varying vec2 vTextureCoord;

uniform mat4 uMVPMatrix;
uniform mat4 uSTMatrix;
uniform vec2 uCenter;
uniform float uRadius;
uniform float uTime;
uniform float uAmplitude;
uniform float uFrequency;

const float PI = 3.1415926;

void main() {
    // 计算顶点到中心点的距离
    vec2 position = aPosition.xy;
    float distanceToCenter = distance(position, uCenter);

    // 计算呼吸缩放幅度
    float scale = 1.0 + uAmplitude * sin(uTime * uFrequency * 2.0 * PI);

    // 如果顶点距离中心点在作用半径范围内，应用呼吸效果
    if (distanceToCenter < uRadius) {
        float influence = 1.0 - (distanceToCenter / uRadius);
        scale = mix(1.0, scale, influence);
    } else {
        scale = 1.0;  // 不在半径内的顶点保持不变
    }

    // 应用缩放到顶点
    gl_Position = uMVPMatrix * (aPosition * scale);

    // 传递纹理坐标到片元着色器
    vTextureCoord = (uSTMatrix * aTextureCoord).xy;
}
